home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Development Platforms / Apple II / Essentials / MPW IIGS Interfaces / CIIGSIncludes / TextEdit.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-08-01  |  13.7 KB  |  464 lines  |  [TEXT/MPS ]

  1. /********************************************
  2. ; File: TextEdit.h
  3. ;
  4. ;
  5. ; Copyright Apple Computer, Inc.1986-90
  6. ; All Rights Reserved
  7. ;
  8. ********************************************/
  9.  
  10. #ifndef __TYPES__
  11. #include <TYPES.h>
  12. #endif
  13.  
  14. #ifndef __QUICKDRAW__
  15. #include <QUICKDRAW.h>
  16. #endif
  17.  
  18. #ifndef __EVENT__
  19. #include <EVENT.h>
  20. #endif
  21.  
  22. #ifndef __FONT__
  23. #include <FONT.h>
  24. #endif
  25.  
  26. #ifndef __GSOS__
  27. #include <GSOS.h>
  28. #endif
  29.  
  30. #ifndef __RESOURCES__
  31. #include <RESOURCES.h>
  32. #endif
  33.  
  34. #ifndef __CONTROL__
  35. #include <CONTROL.h>
  36. #endif
  37.  
  38. #ifndef __TEXTEDIT__
  39. #define __TEXTEDIT__
  40.  
  41.  
  42. /* Error Codes */
  43. #define teAlreadyStarted 0x2201
  44. #define teNotStarted 0x2202
  45. #define teInvalidHandle 0x2203
  46. #define teInvalidVerb 0x2204
  47. #define teInvalidFlag 0x2205
  48. #define teInvalidPCount 0x2206
  49. #define teInvalidRect 0x2207
  50. #define teBufferOverflow 0x2208
  51. #define teInvalidLine 0x2209
  52. #define teInvalidCall 0x220A
  53.  
  54. /* TE Verbs */
  55. #define NullVerb 0x0000
  56. #define PStringVerb 0x0001
  57. #define CStringVerb 0x0002
  58. #define C1InputVerb 0x0003
  59. #define C1OutputVerb 0x0004
  60. #define HandleVerb 0x0005
  61. #define PointerVerb 0x0006
  62. #define NewPStringVerb 0x0007
  63. #define fEqualLineSpacing 0x8000
  64. #define fShowInvisibles 0x4000
  65. #define teInvalidDescriptor 0x2204
  66. #define teInvalidParameter 0x220B
  67. #define teInvalidTextBox2 0x220C
  68. #define teNeedsTools 0x220D  /* 8717 */
  69. #define teEqualLineSpacing 0x8000
  70. #define teShowInvisibles 0x4000
  71.  
  72. /* Justification Values */
  73. #define leftJust 0x0000
  74. #define rightJust 0xFFFF
  75. #define centerJust 0x0001
  76. #define fullJust 0x0002
  77.  
  78. /* TERuler.tabType Codes */
  79. #define noTabs 0x0000
  80. #define stdTabs 0x0001  /* Tabs every tabTerminator pixels */
  81. #define absTabs 0x0002  /* Tabs at absolute location specified by theTabs array */
  82.  
  83. /* TEParamBlock.flags Codes */
  84. #define fCtlInvis 0x0080
  85. #define fRecordDirty 0x0040
  86.  
  87. /* TE Tab Codes */
  88. #define teLeftTab 0x0000
  89. #define teCenterTab 0x0001
  90. #define teRightTab 0x0002
  91. #define teDecimalTab 0x0003
  92.  
  93. /* TEParamBlock.textFlags Codes */
  94. #define fNotControl 0x80000000L  /* TextEdit record is not a control */
  95. #define fSingleFormat 0x40000000L  /* Only one ruler is allowed for record */
  96. #define fSingleStyle 0x20000000L  /* Only one style is allowed for record */
  97. #define fNoWordWrap 0x10000000L  /* No word wrap is performed */
  98. #define fNoScroll 0x08000000L  /* The text cannot scroll */
  99. #define fReadOnly 0x04000000L  /* The text cannot be edited */
  100. #define fSmartCutPaste 0x02000000L  /* Record supports intelligent cut and paste */
  101. #define fTabSwitch 0x01000000L  /* Tab key switches user to next TextEdit record on the screen */
  102. #define fDrawBounds 0x00800000L  /* TextEdit draw a box around text */
  103. #define fColorHilight 0x00400000L  /* Use color table for highlighting */
  104. #define fGrowRuler 0x00200000L  /* Adjust right margin whenever window size changes */
  105. #define fDisableSelection 0x00100000L  /* User cannot select or edit text */
  106. #define fDrawInactiveSelection 0x00080000L  /* TextEdit displays a box around an inactive selection */
  107.  
  108. /* Descriptor Codes */
  109. #define teCtlColorIsPtr 0x0000
  110. #define teCtlColorIsHandle 0x0004
  111. #define teCtlColorIsResource 0x0008
  112. #define teCtlStyleIsPtr 0x0000
  113. #define teCtlStyleIsHandle 0x0001
  114. #define teCtlStyleIsResource 0x0002
  115. #define teRefIsPtr 0x0000
  116. #define teRefIsHandle 0x0001
  117. #define teRefIsResource 0x0002
  118. #define teRefIsNewHandle 0x0003
  119. #define teDataIsPString 0x0000
  120. #define teDataIsCString 0x0001
  121. #define teDataIsC1Input 0x0002
  122. #define teDataIsC1Output 0x0003
  123. #define teDataIsTextBox2 0x0004
  124. #define teDataIsTextBlock 0x0005
  125. #define teTextIsPtr 0x0000
  126. #define teTextIsHandle 0x0008
  127. #define teTextIsResource 0x0010
  128. #define teTextIsNewHandle 0x0018
  129.  
  130. /* TEGetLastError clearFlag Codes */
  131. #define fLeaveError 0x0000  /* Leave the last error code intact */
  132. #define fClearError 0xFFFF  /* Clear the last error code */
  133.  
  134. /* Other Constants */
  135. #define teInvis 0x4000
  136. #define tePartialLines 0x8000L
  137. #define teDontDraw 0x4000
  138. #define teUseFont 0x0020
  139. #define teUseSize 0x0010
  140. #define teUseForeColor 0x0008
  141. #define teUseBackColor 0x0004
  142. #define teUseUserData 0x0002
  143. #define teUseAttributes 0x0001
  144. #define teReplaceFont 0x0040
  145. #define teReplaceSize 0x0020
  146. #define teReplaceForeColor 0x0010
  147. #define teReplaceBackColor 0x0008
  148. #define teReplaceUserField 0x0004
  149. #define teReplaceAttributes 0x0002
  150. #define teSwitchAttributes 0x0001
  151.  
  152. /* Filter Procedure Commands */
  153. #define doEraseRect 0x0001
  154. #define doEraseBuffer 0x0002
  155. #define doRectChanged 0x0003
  156. #define doKeyStroke 0x0004
  157.  
  158. /* TEScroll descriptors */
  159. #define teScrollAbsTop 0x0000  /* 0 */
  160. #define teScrollAbsCenter 0x0001  /* 1 */
  161. #define teScrollLineTop 0x0002  /* 2 */
  162. #define teScrollLineCenter 0x0003  /* 3 */
  163. #define teScrollAbsUnit 0x0004  /* 4 */
  164. #define teScrollRelUnit 0x0005  /* 5 */
  165.  
  166. struct TETextBlock {
  167.    struct TETextBlock **nextHandle; /* Handle to next TextBlock in list */
  168.    struct TETextBlock **prevHandle; /* Handle to previous TextBlock in list */
  169.    LongWord textLength; /* Number of bytes of theText */
  170.    Word flags;
  171.    Word reserved; /* Reserved */
  172.    Byte theText[1]; /* textLength bytes of text  */
  173. } ;
  174. typedef struct TETextBlock TETextBlock, *TETextBlockPtr, **TETextBlockHndl;
  175.  
  176. struct TETextList {
  177.    TETextBlockHndl cachedHandle; /* Handle to current TextBlock */
  178.    LongWord cachedOffset; /* Text offset of the start of the current TextBlock */
  179. } ;
  180. typedef struct TETextList TETextList, *TETextListPtr, **TETextListHndl;
  181.  
  182. struct TEColorTable {
  183.    Word contentColor;
  184.    Word outlineColor;
  185.    Word hiliteForeColor;
  186.    Word hiliteBackColor;
  187.    Word vertColorDescriptor;
  188.    LongWord vertColorRef;
  189.    Word horzColorDescriptor;
  190.    LongWord horzColorRef;
  191.    Word growColorDescriptor;
  192.    LongWord growColorRef;
  193. } ;
  194. typedef struct TEColorTable TEColorTable, *TEColorTablePtr, **TEColorTableHndl;
  195.  
  196. struct TEBlockEntry {
  197.    Handle text; /*   */
  198.    Handle length; /*   */
  199.    Word flags; /*   */
  200. } ;
  201. typedef struct TEBlockEntry TEBlockEntry;
  202.  
  203. struct TEBlocksRecord {
  204.    LongWord start; /*   */
  205.    Word index; /*   */
  206.    TEBlockEntry blocks[1]; /*   */
  207. } ;
  208. typedef struct TEBlocksRecord TEBlocksRecord, *TEBlocksPtr, **TEBlocksHndl;
  209.  
  210. struct TabItem {
  211.    Word tabKind;
  212.    Word tabData;
  213. } ;
  214. typedef struct TabItem TabItem;
  215.  
  216. struct TESuperItem {
  217.    LongWord itemLength; /*   */
  218.    LongWord itemData; /*   */
  219. } ;
  220. typedef struct TESuperItem TESuperItem, *TESuperItemPtr, **TESuperItemHndl;
  221.  
  222. struct TESuperBlock {
  223.    struct TESuperBlock **nextHandle; /*   */
  224.    struct TESuperBlock **prevHandle; /*   */
  225.    LongWord textLength; /*   */
  226.    LongWord reserved; /*   */
  227.    TESuperItem theItems[1]; /*   */
  228. } ;
  229. typedef struct TESuperBlock TESuperBlock, *TESuperBlockPtr, **TESuperBlockHndl;
  230.  
  231. struct TESuperHandle {
  232.    TESuperBlockHndl cachedHandle; /*   */
  233.    LongWord cachedOffset; /*   */
  234.    Word cachedIndex; /*   */
  235.    Word itemsPerBlock; /*   */
  236. } ;
  237. typedef struct TESuperHandle TESuperHandle, *TESuperHandlePtr, **TESuperHandleHndl;
  238.  
  239. struct TERuler {
  240.    Word leftMargin;
  241.    Word leftIndent;
  242.    Word rightMargin;
  243.    Word just;
  244.    Word extraLS;
  245.    Word flags;
  246.    LongWord userData;
  247.    Word tabType;
  248.    TabItem theTabs[1];
  249.    Word tabTerminator;
  250. } ;
  251. typedef struct TERuler TERuler, *TERulerPtr, **TERulerHndl;
  252.  
  253. struct TEStyle {
  254.    FontID styleFontID;
  255.    Word foreColor;
  256.    Word backColor;
  257.    LongWord userData;
  258. } ;
  259. typedef struct TEStyle TEStyle, *TEStylePtr, **TEStyleHndl;
  260.  
  261. struct TEStyleGroup {
  262.    Word count; /*   */
  263.    TEStyle styles[1]; /*   */
  264. } ;
  265. typedef struct TEStyleGroup TEStyleGroup, *TEStyleGroupPtr, **TEStyleGroupHndl;
  266.  
  267. struct StyleItem {
  268.    LongWord dataLength; /* Number of text characters using the style */
  269.    LongWord dataOffset; /* Byte offset into theStyleList entry */
  270. } ;
  271. typedef struct StyleItem StyleItem, *StyleItemPtr, **StyleItemHndl;
  272.  
  273. typedef long TERulerRef;
  274.  
  275. /*
  276.     The following data structure (TEFormat) is for reference only!
  277.     It contains embedded variable length fields.
  278. */
  279.  
  280. struct TEFormat {
  281.    Word version;
  282.    LongWord rulerListLength;
  283.    TERuler theRulerList[1];
  284.    LongWord styleListLength;
  285.    TEStyle theStyleList[1];
  286.    LongWord numberOfStyles;
  287.    StyleItem theStyles[1];
  288. } ;
  289. typedef struct TEFormat TEFormat, *TEFormatPtr, **TEFormatHndl;
  290.  
  291. typedef struct TETextRef {
  292.      Ptr TETextDesc;
  293. } TETextRef,*TETextRefPtr, **TETextRefHndl;
  294.  
  295. typedef struct TEStyleRef {
  296.       Ptr TEStyleDesc ;
  297. } TEStyleRef,*TEStyleRefPtr,**TEStyleRefHndl ;
  298.  
  299. typedef long TEColorRef;
  300.  
  301. struct TEParamBlock {
  302.    Word pCount;
  303.    LongWord controlID;
  304.    Rect boundsRect;
  305.    LongWord procRef;
  306.    Word flags;
  307.    Word moreflags;
  308.    LongWord refCon;
  309.    LongWord textFlags;
  310.    Rect indentRect;
  311.    CtlRecHndl vertBar;
  312.    Word vertAmount;
  313.    CtlRecHndl horzBar;
  314.    Word horzAmount;
  315.    TEStyleRef styleRef;
  316.    Word textDescriptor;
  317.    TETextRef textRef;
  318.    LongWord textLength;
  319.    LongWord maxChars;
  320.    LongWord maxLines;
  321.    Word maxCharsPerLine;
  322.    Word maxHeight;
  323.    TEColorRef colorRef;
  324.    Word drawMode;
  325.    ProcPtr filterProcPtr;
  326. } ;
  327. typedef struct TEParamBlock TEParamBlock, *TEParamBlockPtr, **TEParamBlockHndl;
  328.  
  329. struct TEInfoRec {
  330.    LongWord charCount; /*   */
  331.    LongWord lineCount; /*   */
  332.    LongWord formatMemory; /*   */
  333.    LongWord totalMemory; /*   */
  334.    LongWord styleCount; /*   */
  335.    LongWord rulerCount; /*   */
  336. } ;
  337. typedef struct TEInfoRec TEInfoRec;
  338.  
  339. struct TEHooks {
  340.    ProcPtr charFilter; /*   */
  341.    ProcPtr wordWrap; /*   */
  342.    ProcPtr wordBreak; /*   */
  343.    ProcPtr drawText; /*   */
  344.    ProcPtr eraseText; /*   */
  345. } ;
  346. typedef struct TEHooks TEHooks;
  347.  
  348. struct TEKeyRecord {
  349.    Word theChar; /*   */
  350.    Word theModifiers; /*   */
  351.    Handle theInputHandle; /*   */
  352.    LongWord cursorOffset; /*   */
  353.    Word theOpCode; /*   */
  354. } ;
  355. typedef struct TEKeyRecord TEKeyRecord, *TEKeyRecordPtr, **TEKeyRecordHndl;
  356.  
  357. struct TERecord {
  358.    CtlRecHndl ctrlNext; /*   */
  359.    WindowPtr inPort; /*   */
  360.    Rect boundsRect; /*   */
  361.    Byte ctrlFlag; /*   */
  362.    Byte ctrlHilite; /*   */
  363.    Word lastErrorCode; /*   */
  364.    ProcPtr ctrlProc; /*   */
  365.    ProcPtr ctrlAction; /*   */
  366.    ProcPtr filterProc; /*   */
  367.    LongWord ctrlRefCon; /*   */
  368.    TEColorTablePtr colorRef; /*   */
  369.    LongWord textFlags; /*   */
  370.    LongWord textLength; /*   */
  371.    TETextList blockList; /*   */
  372.    LongWord ctrlID; /*   */
  373.    Word ctrlMoreFlags; /*   */
  374.    Word ctrlVersion; /*   */
  375.    Rect viewRect; /*   */
  376.    LongWord totalHeight; /*   */
  377.    TESuperHandle lineSuper; /*   */
  378.    TESuperHandle styleSuper; /*   */
  379.    Handle styleList; /*   */
  380.    Handle rulerList; /*   */
  381.    Boolean lineAtEndFlag; /*   */
  382.    LongWord selectionStart; /*   */
  383.    LongWord selectionEnd; /*   */
  384.    Word selectionActive; /*   */
  385.    Word selectionState; /*   */
  386.    LongWord caretTime; /*   */
  387.    Boolean nullStyleActive; /*   */
  388.    TEStyle nullStyle; /*   */
  389.    LongWord topTextOffset; /*   */
  390.    Word topTextVPos; /*   */
  391.    CtlRecHndl vertScrollBar; /*   */
  392.    LongWord vertScrollPos; /*   */
  393.    LongWord vertScrollMax; /*   */
  394.    Word vertScrollAmount; /*   */
  395.    CtlRecHndl horzScrollBar; /*   */
  396.    LongWord horzScrollPos; /*   */
  397.    LongWord horzScrollMax; /*   */
  398.    Word horzScrollAmount; /*   */
  399.    CtlRecHndl growBoxHandle; /*   */
  400.    LongWord maximumChars; /*   */
  401.    LongWord maximumLines; /*   */
  402.    Word maxCharsPerLine; /*   */
  403.    Word maximumHeight; /*   */
  404.    Word textDrawMode; /*   */
  405.    ProcPtr wordBreakHook; /*   */
  406.    ProcPtr wordWrapHook; /*   */
  407.    ProcPtr keyFilter; /*   */
  408.    Rect theFilterRect; /*   */
  409.    Word theBufferVPos; /*   */
  410.    Word theBufferHPos; /*   */
  411.    TEKeyRecord theKeyRecord; /*   */
  412.    LongWord cachedSelcOffset; /*   */
  413.    Word cachedSelcVPos; /*   */
  414.    Word cachedSelcHPos; /*   */
  415.    Rect mouseRect; /*   */
  416.    LongWord mouseTime; /*   */
  417.    Word mouseKind; /*   */
  418.    Point lastClick; /*   */
  419.    Word savedHPos; /*   */
  420.    LongWord anchorPoint; /*   */
  421. } ;
  422. typedef struct TERecord TERecord, *TERecordPtr, **TERecordHndl;
  423.  
  424. extern pascal void TEActivate() inline(0x0F22,dispatcher);
  425. extern pascal void TEBootInit() inline(0x0122,dispatcher);
  426. extern pascal void TEClear() inline(0x1922,dispatcher);
  427. extern pascal void TEClick() inline(0x1122,dispatcher);
  428. extern pascal void TECompactRecord() inline(0x2822,dispatcher);
  429. extern pascal void TECopy() inline(0x1722,dispatcher);
  430. extern pascal void TECut() inline(0x1622,dispatcher);
  431. extern pascal void TEDeactivate() inline(0x1022,dispatcher);
  432. extern pascal ProcPtr TEGetDefProc() inline(0x2222,dispatcher);
  433. extern pascal ProcPtr TEGetInternalProc() inline(0x2622,dispatcher);
  434. extern pascal Word TEGetLastError() inline(0x2722,dispatcher);
  435. extern pascal void TEGetRuler() inline(0x2322,dispatcher);
  436. extern pascal void TEGetSelection() inline(0x1C22,dispatcher);
  437. extern pascal Word TEGetSelectionStyle() inline(0x1E22,dispatcher);
  438. extern pascal LongWord TEGetText() inline(0x0C22,dispatcher);
  439. extern pascal void TEGetTextInfo() inline(0x0D22,dispatcher);
  440. extern pascal void TEIdle() inline(0x0E22,dispatcher);
  441. extern pascal void TEInsert() inline(0x1A22,dispatcher);
  442. extern pascal void TEInsertPageBreak() inline(0x1522,dispatcher);
  443. extern pascal void TEKey() inline(0x1422,dispatcher);
  444. extern pascal void TEKill() inline(0x0A22,dispatcher);
  445. extern pascal TERecordHndl TENew() inline(0x0922,dispatcher);
  446. extern pascal void TEOffsetToPoint() inline(0x2022,dispatcher);
  447. extern pascal LongWord TEPaintText() inline(0x1322,dispatcher);
  448. extern pascal void TEPaste() inline(0x1822,dispatcher);
  449. extern pascal LongWord TEPointToOffset() inline(0x2122,dispatcher);
  450. extern pascal void TEReplace() inline(0x1B22,dispatcher);
  451. extern pascal void TEReset() inline(0x0522,dispatcher);
  452. extern pascal void TEScroll() inline(0x2522,dispatcher);
  453. extern pascal void TESetRuler() inline(0x2422,dispatcher);
  454. extern pascal void TESetSelection() inline(0x1D22,dispatcher);
  455. extern pascal void TESetText() inline(0x0B22,dispatcher);
  456. extern pascal void TEShutDown() inline(0x0322,dispatcher);
  457. extern pascal void TEStartUp() inline(0x0222,dispatcher);
  458. extern pascal Word TEStatus() inline(0x0622,dispatcher);
  459. extern pascal void TEStyleChange() inline(0x1F22,dispatcher);
  460. extern pascal void TEUpdate() inline(0x1222,dispatcher);
  461. extern pascal Word TEVersion() inline(0x0422,dispatcher);
  462.  
  463. #endif
  464.